#include "TextArea.h"
#include "NormalText.h"
#include "HeaderText.h"
#include "ColorText.h"

TextArea::TextArea(const Area& area, const Color& backgroundColor)
        : BackgroundColor(area, backgroundColor), nextTextPos(10)
{
}

TextArea::~TextArea()
{
}

Text* TextArea::addNormalLine(std::string text)
{
    return addLine(new NormalText(Position(10, nextTextPos), text));
}

Text* TextArea::addHeaderLine(std::string text)
{
    return addLine(new HeaderText(Position(10, nextTextPos), text));
}

Text* TextArea::addColorLine(const Color& color, std::string text)
{
    return addLine(new ColorText(Position(10, nextTextPos), color, text));
}

void TextArea::addEmptySpace()
{
    nextTextPos += 15;
}

Text* TextArea::addLine(Text* text)
{
    addChild(text);
    nextTextPos += text->getFontSize();
    return text;
}

void TextArea::clear()
{
    eraseChildren();
    nextTextPos = 10;
}
